/**
 * @date 2006-7-18
 */

package org.nanhill.xmlro.gsp;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.nanhill.xmlro.gsp.client.DefaultGspAgent;
import org.nanhill.xmlro.gsp.client.GspAgent;

/**
 * @author alin [xalinx at gmail dot com]
 * @date 2006-7-18
 */
public class ReportAllSample {



	/**
	 * @param args
	 * @throws GspException
	 */
	public static void main(String[] args) {
		// create agent bind with sls module name
		GspAgent importAgent = new DefaultGspAgent("hawaii.kernel.sls");
		try {
			importAgent.setServiceHost("192.168.3.4");
			importAgent.setServicePort(2001);
			// set gsp service name and version
			importAgent.setServiceType("hawaii.kernel.sls.monitor", "1");
			// do gsp service by service command and transport object
			Map result = (Map) importAgent.doService("reportAll", null);
			List services = (List)result.get("services");
			for (Object item : services) {
				Map service = (Map)item;
				String name = (String)service.get("name");
				System.out.println(name);
			}
			// ----------- close ------------
			importAgent.close();
		} catch (GspException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
